package com.mycompany.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mycompany.dao.InvoiceDao;
import com.mycompany.model.Invoice;
import com.mycompany.service.InvoiceManager;

@Service("invoiceManager")
public class InvoiceManagerImpl implements InvoiceManager {
	private InvoiceDao invoiceDao;
	
	
	@Override
	public List<Invoice> getInvoices(int page, int pageSize) {
		return invoiceDao.getInvoices(page, pageSize);
	}


	public InvoiceDao getInvoiceDao() {
		return invoiceDao;
	}

	@Autowired
	public void setInvoiceDao(InvoiceDao invoiceDao) {
		this.invoiceDao = invoiceDao;
	}


	@Override
	public int getTotalInvoices() {
		return getInvoices(0,0).size();
	}


	@Override
	public void updateName(Long id, String name) {
		Invoice invoice = invoiceDao.getInvoice(id);
		invoice.setName(name);
	}

	
}
